package com.itheima.utils;

import io.jsonwebtoken.*;

import java.util.Date;
import java.util.Map;

public class JwtUtils {

    private final static String key = "123456";

    public static String createJwt(Map<String, Object> map) {
        //String compact =
        return Jwts.builder()
                .signWith(SignatureAlgorithm.HS256, key)
                .setClaims(map)
                .setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24))
                .compact();
        // return compact;
    }

    public static Map<String, Object> Jwt(String jwt) throws SignatureException, ExpiredJwtException {
        //Claims body =
        return Jwts.parser()
                .setSigningKey(key)
                .parseClaimsJws(jwt)
                .getBody();
        //return body;
    }

}
